package au.com.identityconcepts.windowslive.sso.ws;

import com.microsoft.schemas.passport.soapservices.credentialserviceapi.v1.EnumSHVersion;
import com.microsoft.schemas.passport.soapservices.credentialserviceapi.v1.PASSIDTYPE;
import com.microsoft.schemas.passport.soapservices.credentialserviceapi.v1.TagPASSID;
import com.microsoft.schemas.passport.soapservices.credentialserviceapi.v1.TagWSSECURITYHEADER;

public class Marshall {

	public static String GetSLT(Session session, String username, int loginSeconds) {
		
		String slt = null;
		String ppSoapHeader25 = "<s:ppSoapHeader xmlns:s=\"http://schemas.microsoft.com/Passport/SoapServices/SoapHeader\"" +
			" version=\"1.0\"><s:lcid>1033</s:lcid>" +
			"<s:sitetoken><t:siteheader xmlns:t=\"http://schemas.microsoft.com/Passport/SiteToken\" id=\"" + session.siteID + "\"/></s:sitetoken>" +
			"</s:ppSoapHeader>";
		
		TagWSSECURITYHEADER wsSec = new TagWSSECURITYHEADER();	            	
		wsSec.setVersion(EnumSHVersion.ESH_HEADER_25);			

		wsSec.setPpSoapHeader25(ppSoapHeader25);
		TagPASSID passID = new TagPASSID();
		passID.setPit(PASSIDTYPE.PASSID_SIGNINNAME);
		passID.setBstrID(username);		    		    				    		    		
			
		// XMLStream
		/*			  
		try {
			StreamInterceptorJDOM cus = new StreamInterceptorJDOM();
			session.client.getOutInterceptors().add(cus);
		} catch (Exception e ) {
			System.out.println(e.toString());
		}		
		*/											
		slt = session.port.getSLT(passID, loginSeconds, wsSec);					
		return slt;
	}
}
